<%-- 
    Document   : index
    Created on : Apr 2, 2013, 8:24:17 PM
    Author     : T-Rain
--%>

<%@page import="java.text.DecimalFormat"%>
<%@page import="java.text.DecimalFormatSymbols"%>
<%@page import="TrangSuc.Giohang"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="Func.Conn"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
     <%@ include file="head.jsp" %>
<%
        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
        decimalFormatSymbols.setDecimalSeparator('.');
        decimalFormatSymbols.setGroupingSeparator(',');
        DecimalFormat decimalFormat = new DecimalFormat("#,##0", decimalFormatSymbols);
%>
<body>
<div id="divContainer">
    
    <%@ include file="divHeader.jsp" %>
	
    </br>		
    <div class="clr"></div>
				
    <%@ include file="divLeft.jsp" %>
    
	<div id = "divMid">
            <div id ="pro4">
          <center>   <h1>  THÔNG TIN CHI TIẾT SẢN PHẨM  </h1> </center>
          
                <%   
                      Connection con = Conn.GetCon();
 Statement statement = con.createStatement();
 Statement statement1 = con.createStatement();
 ResultSet resultSet1 ;

// Execute a statement
 ResultSet resultSet2 = statement1.executeQuery
 ("select * from thongtinsanpham ttsp, thongtinchungloai ttcl, thongtinloaida ttld, thongtinloaitrangsuc ttlts"+
  " where ttsp.machungloai = ttcl.machungloai"+
  " and ttsp.maloaida = ttld.maloaida"+
  " and ttsp.maloaitrangsuc = ttlts.maloaitrangsuc "+
  "and ttsp.masp = '"+ request.getParameter("id") +"' ");
String url = "";
String url1 = "";
while (resultSet2.next())
{
    url = resultSet2.getString("urlhinh") + "1s.jpg";
    url1 = resultSet2.getString("urlhinh") + "1b.jpg";
%></br><a href="<% out.print(url1); %> " class = "cloud-zoom" id="zoom1" rel="adjustX: 10, adjustY:-4" >
<%
    out.println("<img src ="+ url +" alt=''></a>" );
    out.println("<center><table border='0' >");
    out.println  ("<tr><td >");
out.println("<form action = 'Xuly?act=cart&id="+ resultSet2.getString("MaSP") +"&sl=1' method = 'post'>");
out.println("<input class='btmua' type=\"submit\" value=\"Mua Hàng\">");

out.println("</form>");
out.println("</td>");
out.println("</tr>");
out.println("</table></center>");
}
 
 
 
 
 ResultSet resultSet = statement.executeQuery
 ("select * from thongtinsanpham ttsp, thongtinchungloai ttcl, thongtinloaida ttld, thongtinloaitrangsuc ttlts"+
  " where ttsp.machungloai = ttcl.machungloai"+
  " and ttsp.maloaida = ttld.maloaida"+
  " and ttsp.maloaitrangsuc = ttlts.maloaitrangsuc "+
  "and ttsp.masp = '"+ request.getParameter("id") +"' ");

out.println("<center><table width='49%' border='1' align='center' >");
out.println("<tr align = 'center'>");

// Iterate through the result and print the student names
while (resultSet.next())
    
      {
  
    out.println("<td colspan = 2 >");
    
out.println(""+ resultSet.getString("TenChungLoai")+" "+ request.getParameter("id")+"</td></tr>");
out.println("<tr><td> Chất Liệu : </td>");
out.println("<td>"+ resultSet.getString("tenloaitrangsuc") +" </td> </tr>");
out.println("<tr><td> Loại đá : </td>");
out.println("<td>"+ resultSet.getString("tenloaida") +" </td> </tr>");
out.println("<tr><td> Trọng Lượng : </td>");
out.println("<td>"+ resultSet.getString("trongluong") +" </td> </tr>");
    if(  resultSet.getInt("makhuyenmai") == 0)
        {
            out.println("<tr><td> Giá : </td>");
            out.println("<td>"+ decimalFormat.format( resultSet.getDouble("gia")) +" VND </td> </tr>");
        }
 else
         {
out.println("<tr><td> Giá khuyến mãi : </td><td>"+ decimalFormat.format((resultSet.getDouble("Gia") - (resultSet.getDouble("Gia")* resultSet.getDouble("MaKhuyenMai"))/10)) +" VND </td></tr> ");
out.println("<tr><td> Giá cũ : </td><td>"+decimalFormat.format( resultSet.getDouble("Gia")) +" VND </td></tr> ");
        }

 
 
}       
out.println("</table><center>");

 
 
               %> 
            </div>
        </div>
       
    <%@ include file="divFooter.jsp" %>  
         </div>

    </body>
</html>
